import request from '@/utils/axios'
import assist from '@/utils/commonality'

export function priceTemplate(params) { //获取价格模板
  return request({
    url: '/qy/template',
    method: 'get',
    params: {
      app_id: assist.getAppId(),
      channel_id: assist.getChannelId(),
      packet: assist.getPacket(),
      other_id: assist.getOtherId()
    }
  })
}



/**
 * 
 * @param {价格模板的id} shopid 
 * @param {项目的名称,默认是h5} name 
 * @returns 
 */
export async function getPriceUrl(shopid,name='suno写歌') { //获取支付的二维码
  return request({
    url: '/qy/pay_qrcode',
    method: 'get',
    params: {
      appid: assist.getAppId(),
      channel_id: assist.getChannelId(),
      packet: assist.getPacket(),
      other_id: assist.getOtherId(),
      uid:await assist.getUid(),
      custom: JSON.stringify({
        shop_name: name,
        shop_id: shopid,   //shopid是价格模板里面的id
      }),
      shop_id: shopid,
      redirect_url: window.location.href,
    }
  })
}
// 参数有
// appid: assist.getAppId(),
// channel_id: assist.getChannelId(),
// packet: assist.getPacket(), 
// other_id: assist.getOtherId(),
// uid: this.isuid,
// custom: JSON.stringify({
//              shop_name: '图片视频压缩',
//              shop_id: shopid,   //shopid是价格模板里面的id
//    }),
// shop_id: shopid,
// redirect_url: window.location.href,



/**
 * 
 * @param {订单号} out_trade_no 
 * @returns 
 */
export async function inquirePaySuces(out_trade_no) { //查询是否支付成功
  return request({
    url: '/pay/orders',
    method: 'get',
    params:{
      uid:await assist.getUid(),
      out_trade_no: out_trade_no
    }
  })
}
// 参数
// uid: this.isuid,
// out_trade_no: this.wxiszfbEwm.wx.out_trade_no


export function bingApi(params) { //查询bing
  return request({
    url: '/qy/bing_back',
    method: 'get',
    params
  })
}

